package com.ymttest.database.mapping;

import com.ymttest.database.model.DGThirdPartyBindInfo;
import com.ymttest.database.model.DGUserExtInfo;
import com.ymttest.database.model.DGUserInfo;
import com.ymttest.database.model.DGWxAppConfig;
import com.ymttest.database.model.DGWxUnionidBindInfo;
import com.ymttest.database.model.dguser.DGLoginLog;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface DGUserMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userinfo
     *
     * @mbggenerated Fri Mar 08 16:01:56 CST 2019
     */
    @Insert({
        "insert into userinfo (UserId, LoginId, ",
        "Mobile, MobileAreaCode, ",
        "LoginPwd, UserType, ",
        "UserGender, UserStatus, ",
        "Nickname, LogoUrl, ",
        "BelongSellerId, IsCs, ",
        "LastLoginTime, CreateTime, ",
        "UpdateTime)",
        "values (#{userId,jdbcType=INTEGER}, #{loginId,jdbcType=VARCHAR}, ",
        "#{mobile,jdbcType=VARCHAR}, #{mobileAreaCode,jdbcType=VARCHAR}, ",
        "#{loginPwd,jdbcType=VARCHAR}, #{userType,jdbcType=INTEGER}, ",
        "#{userGender,jdbcType=INTEGER}, #{userStatus,jdbcType=INTEGER}, ",
        "#{nickname,jdbcType=VARCHAR}, #{logoUrl,jdbcType=VARCHAR}, ",
        "#{belongSellerId,jdbcType=INTEGER}, #{isCs,jdbcType=BIT}, ",
        "#{lastLoginTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{updateTime,jdbcType=TIMESTAMP})"
    })
    int insert(DGUserInfo record);
    
    @Insert({
        "insert into wxappconfig (AppName, AppId, ",
        "Secret, BelongSellerId, ",
        "UserType, CreateTime, ",
        "UpdateTime, AliPublicKey, ",
        "MchPrivateKey)",
        "values (#{AppName,jdbcType=VARCHAR}, #{AppId,jdbcType=VARCHAR}, ",
        "#{Secret,jdbcType=VARCHAR}, #{BelongSellerId,jdbcType=BIGINT}, ",
        "#{UserType,jdbcType=INTEGER}, NOW(), ",
        "NOW(), #{AliPublicKey,jdbcType=VARCHAR}, ",
        "#{MchPrivateKey,jdbcType=VARCHAR})"
    })
    int insertWxAppConfig(DGWxAppConfig record);
    
    /**
     * @param m uid
     * @return
     */
    @Select("select * from userinfo where userid=#{uid}")
    List<DGUserInfo> selectDGUserInfo(Map m);
    @Select("select * from userextinfo where userid=#{uid} ")
    List<DGUserExtInfo> selectDGUserExtInfo(Map m);
    @Select("select * from thirdpartybindinfo where userid=#{uid} order by bindid desc")
    List<DGThirdPartyBindInfo> selectDGThirdPartyBindInfo(Map m);
    @Select("select * from thirdpartybindinfo where openid=#{openId} order by bindid desc")
    List<DGThirdPartyBindInfo> selectDGThirdPartyOpenId(Map m);
    @Select("select * from thirdpartybindinfo where unionid=#{unionid} order by bindid desc")
    List<DGThirdPartyBindInfo> selectDGThirdPartyByUnionId(Map m);
    @Select("select * from wxunionidbindInfo where userid=#{uid} order by bindid desc")
    List<DGWxUnionidBindInfo> selectDGWxUnionidBindInfo(Map m);
    @Update("update userinfo set UserStatus=#{status} where userid=#{uid}")
    int updateDGUserStatus(Map m);
    @Select("select * from loginlog where userid=#{uid} order by id desc limit 100")
    List<DGLoginLog> selectDGLoginLog(Map m);
    
    @Select("select * from wxappconfig where AppName=#{AppName}")
    List<DGWxAppConfig> selectWxAppConfig(Map m);
}